import 'package:flutter/material.dart';
// TapBarView

class Page8 extends StatefulWidget {
  const Page8({super.key});

  @override
  State<Page8> createState() => _Page8State();
}

class _Page8State extends State<Page8> {
  @override
  Widget build(BuildContext context) {
    List<String> tabs = ['Tab1', 'Tab2', 'Tab3', 'Tab4', 'Tab5'];
    return DefaultTabController(
      length: tabs.length,
      child: Scaffold(
        appBar: AppBar(
          title: const Text('TabBarView Example'),
          bottom: TabBar(tabs: tabs.map((tab) => Tab(text: tab)).toList()),
        ),
        body: TabBarView(
          children:
              tabs.map((tab) {
                print('构建Tab: $tab');
                return Center(child: Text('Content for $tab'));
              }).toList(),
        ),
      ),
    );
  }
}
